package com.joinway.framework.admin.core.utils;

import java.util.Calendar;
import java.util.UUID;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.joinway.framework.data.jdbc.repository.TableRepository;

public final class FileProcessUtils {
	
	private final static Logger log = LoggerFactory.getLogger(FileProcessUtils.class);
			
	@Autowired TableRepository repository;
	
//	public static String getText(DomainEntity domain, String fieldName) throws Exception {
//		String text = "";
//		
//		if(PropertyUtils.isReadable(domain, fieldName)){
//			Object value = PropertyUtils.getProperty(domain, fieldName);
//			
//			text = value == null ? "" : String.valueOf(value);
//		}
//		
//		return text.replaceAll("[\\r\\n]", " ");
//	}
	
	public static String getDefaultPageName(){
		return getDefaultPageName(null);
	}
	
	public static String getDefaultPageName(String pageId){
		String id = StringUtils.isBlank(pageId) ? DateFormatUtils.format(Calendar.getInstance(), "yyyyMMdd") : pageId;
		return id + "-" + StringUtils.split(UUID.randomUUID().toString(), "-")[0];
	}

	private FileProcessUtils(){}
}


